package com.lz.sports.ui

import android.os.Bundle
import androidx.lifecycle.lifecycleScope
import com.lz.library.base.BaseActivity
import com.lz.library.extension.click
import com.lz.sports.BR
import com.lz.sports.LogUtils
import com.lz.sports.R
import com.lz.sports.bean.ExamPlan
import com.lz.sports.bean.ExamProject
import com.lz.sports.bean.Examinee
import com.lz.sports.databinding.ActTestBinding
import com.lz.sports.utils.toGson
import com.lz.sports.vm.TestViewModel
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.launch

class TestActivity : BaseActivity<TestViewModel, ActTestBinding>() {

    override fun getLayoutRes(): Int = R.layout.act_test

    override fun getVMVariableId(): Int = BR.vm

    override fun initData(savedState: Bundle?) {
        lifecycleScope.launch {
            arrayOf(binding.testAdd, binding.testBind, binding.testClear).click().collect {
                when (it.id) {
                }
            }
        }
    }





    private fun test00() {
        val examineeList = ArrayList<Examinee>()

        examineeList.add(Examinee().apply {
            studentName = "张三"
            sex = 1
            idCard = "362502199999999999"
            examineesNo = "000001"
            schoolName = "南昌一中"
            schoolAge = "小学本科"
            schoolClass = "2班"
            examPlanCode = "20230020"
            examAreaCode = "202300001"
            examSiteCode = "20231000"

            val examProjectList = intArrayOf(1, 2)
            this.examProjectList = examProjectList
        })

        examineeList.add(Examinee().apply {

            studentName = "李四"
            sex = 1
            idCard = "362502199999999998"
            examineesNo = "000002"
            schoolName = "南昌一中"
            schoolAge = "小学本科"
            schoolClass = "2班"
            examPlanCode = "20230020"
            examAreaCode = "202300001"
            examSiteCode = "20231000"

            val examProjectList = intArrayOf(1, 2)
            this.examProjectList = examProjectList
        })

        examineeList.add(Examinee().apply {

            studentName = "王二麻子"
            sex = 1
            idCard = "362502199999999997"
            examineesNo = "000003"
            schoolName = "南昌一中"
            schoolAge = "小学本科"
            schoolClass = "2班"

            examPlanCode = "20230020"
            examAreaCode = "202300001"
            examSiteCode = "20231000"


            val examProjectList = intArrayOf(1, 2)
            this.examProjectList = examProjectList
        })

        LogUtils.i("json = ${examineeList.toGson()}")
    }

    private fun test01() {
        val examineePlan = ExamPlan()
        examineePlan.planName = "江西省体考"
        examineePlan.id = 10
        examineePlan.planCode = "20230020"
        examineePlan.personThreshold = 80f
        examineePlan.faceThreshold = 70f
        examineePlan.fingerprintThreshold = 90f
        examineePlan.planStartTime = 1701878400000L
        examineePlan.planEndTime = 1702051200000L

        val examProjectList = ArrayList<ExamProject>()

        examProjectList.add(ExamProject().apply {
            id = 1
            examPlanId = 10
            projectName = "中考跳绳"
            projectStartTime = 1701878400000L
            projectEndTime = 1702051200000L


            /*configs = arrayOf(ExamProject.RuleConfig().apply {
                startValue = 50
                endValue = 60
                score = 100
                applicableSex = 1
            }, ExamProject.RuleConfig().apply {
                startValue = 50
                endValue = 60
                score = 100
                applicableSex = 2
            })*/


        })

        examProjectList.add(ExamProject().apply {
            id = 2
            examPlanId = 10
            projectName = "中考跳远"
            projectStartTime = 1701878400000L
            projectEndTime = 1702051200000L

           /* configs = arrayOf(ExamProject.RuleConfig().apply {
                startValue = 50
                endValue = 60
                score = 100
                applicableSex = 1
            }, ExamProject.RuleConfig().apply {
                startValue = 50
                endValue = 60
                score = 100
                applicableSex = 2
            })*/
        })
        examineePlan.examProjectList = examProjectList

        LogUtils.i("json = ${examineePlan.toGson()}")
    }
}